package com.rio.dandan.action;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.beans.propertyeditors.CustomNumberEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;

import com.rio.dandan.bean.PageBean;
import com.rio.dandan.pojo.UserAccount;
import com.rio.dandan.service.UserAccountService;
import com.rio.dandan.service.UserMailService;
import com.rio.dandan.service.UserPhotoService;
import com.rio.dandan.service.UserProfileService;
import com.rio.dandan.service.UserRequireService;
import com.rio.dandan.service.UserScoreService;
import com.rio.dandan.service.UserVideoService;
import com.rio.dandan.service.UserVoiceService;

/**
 * UserManageController.java
 * 
 * @author 宋陆
 * @version 1.0 2014-7-17
 */
@Controller
public class UserManageController {
    @Resource
    UserAccountService userAccountService;
    @Resource
    UserProfileService userProfileService;
    @Resource
    UserRequireService userRequireService;
    @Resource
    UserScoreService userScoreService;
    @Resource
    UserPhotoService userPhotoService;
    @Resource
    UserVoiceService userVoiceService;
    @Resource
    UserVideoService userVideoService;
    @Resource
    UserMailService userMailService;

    /**
     * 我的信息
     * 
     * @param model
     * @return
     */
    @RequestMapping
    public Object info(Integer page, Integer rows) {
        PageBean<UserAccount> pageBean = new PageBean<UserAccount>();
        pageBean.setCurrPage(page);
        pageBean.setPageSize(rows);
        pageBean = userAccountService.findUserAccount(pageBean);
        return pageBean;
    }

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        dateFormat.setLenient(false);
        binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
        binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, false));
        binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, null, true));
        binder.registerCustomEditor(int.class, null, new CustomNumberEditor(Integer.class, null, true));
        binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(Long.class, null, true));
        binder.registerCustomEditor(long.class, null, new CustomNumberEditor(Long.class, null, true));
        binder.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, true));
        binder.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, true));
        binder.registerCustomEditor(BigInteger.class, new CustomNumberEditor(BigInteger.class, true));
    }

}
